<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Promise发送Ajax请求</title>
  <script src="script/jquery-3.7.1.min.js"></script>
  <script type="text/javascript">
    let p = new Promise((resolve, reject) => {
      $.ajax({
        url: `data/cat.json`,
        success(data) {
          console.log("第一次请求data:", data);
          resolve(data);
        },
        error(data) {
          reject(data);
        }
      })
    })
    p.then((data) => {
      return new Promise((resolve, reject) => {
        $.ajax({
          url: `data/cat${data.id}_detail.json`,
          success(data) {
            console.log("第二次请求data:", data);
            resolve(data);
          },
          error(data) {
            reject(data);
          }
        })
      })
    }).then(data => {
      return new Promise((resolve, reject) => {
        $.ajax({
          url: `data/cat${data.gf_id}_detail.json`,
          success(data) {
            console.log("第三次请求data:", data);
            resolve(data);
          },
          error(data) {
            reject(data);
          }
        })
      })
    }).catch(data => {
      console.log("error:", data);
    })
  </script>
</head>
<body>

</body>
</html>
